<%--
  Created by IntelliJ IDEA.
  User: ZHouZHiZHao
  Date: 2021/7/13
  Time: 9:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@include file="../common/common.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/page.css">

	<title> <spring:message code="class.page.title"/></title>

	<script type="text/javascript">
		var _gridWidth;
		var _gridHeight;
		//页面自适应
		function resizePageSize(){
			_gridWidth = $(document).width()-12;/*  -189 是去掉左侧 菜单的宽度，   -12 是防止浏览器缩小页面 出现滚动条 恢复页面时  折行的问题 */
			_gridHeight = $(document).height()-32-80; /* -32 顶部主菜单高度，   -90 查询条件高度*/
		}

		$(function()
		{
			resizePageSize();



			var _columnWidth= (_gridWidth-150)/4;
			$("#flexiGridID").flexigrid({
				width : _gridWidth,
				height : _gridHeight,
				url : "${pageContext.request.contextPath}/recycle/getDeleteFileslist",
				dataType : 'json',
				colModel : [
					{display : "<spring:message code='file.name'/>",name : 'fileName',width : _columnWidth, sortable : false,align : 'center'},
					{display : "<spring:message code='file.content.length'/>",name : 'fileLength',width : _columnWidth, sortable : false,align : 'center'},
					{display : "<spring:message code='file.modify.time'/>",name : 'fileLastTime',width : _columnWidth, sortable : false,align : 'center'},
					{display : "<spring:message code='file.operation'/>",name : 'id',width : _columnWidth, sortable : true,align : 'center',process: function(v,_trid,_row)
						{
							var htmlContents1 ='<a style="color:blue;cursor:pointer;" href="#" onclick="restoreFile(\''+_row.id+'\');"><spring:message code="file.restore"/></a>';
							var htmlContents2 ='<a style="color:blue;cursor:pointer;" href="#" onclick="deleteFile(\''+_row.fileName+'\');"><spring:message code="file.delete"/></a>';

							return htmlContents1 +"|"+htmlContents2;
						}}
				],
				resizable : false, //resizable table是否可伸缩
				useRp : true,
				usepager : false, //是否分页
				autoload : false, //自动加载，即第一次发起ajax请求
				hideOnSubmit : true, //是否在回调时显示遮盖
				showcheckbox : true, //是否显示多选框
				//rowhandler : rowDbclick, //是否启用行的扩展事情功能,在生成行时绑定事件，如双击，右键等
				rowbinddata : true,
				numCheckBoxTitle : "<spring:message code='common.selectall'/>"
			});
			query();
		});

		function query(param1){
			$('#flexiGridID').flexOptions({
				newp: 1,
				extParam: param1||[]
			}).flexReload();
		}

		function restoreFile(id) {
			console.log("id="+id);
			console.log();
			$.ajax({
				type : 'POST',
				url : '${pageContext.request.contextPath}/recycle/restore/'+id+'',
				dataType : 'json',
				cache : false,
				data : {},
				success : function() {
					message("还原成功！")
					$("#flexiGridID").flexReload();
				},
				error : function() {
					message("<spring:message code='common.error'/>");
				},
			});
		}

		function deleteFile(file_name) {
			console.log("file_name="+file_name);
			console.log();
			$.ajax({
				type : 'POST',
				url : '${pageContext.request.contextPath}/recycle/delete/'+file_name+'',
				dataType : 'json',
				cache : false,
				data : {},
				success : function() {
					message("删除成功！")
					$("#flexiGridID").flexReload();
				},
				error : function() {
					message("<spring:message code='common.error'/>");
				},
			});
		}


	</script>

</head>
<body style="display: flex;flex-direction: column">

		<table id="flexiGridID" style="display: block;margin: 0px;">

		</table>

</body>
</html>